﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Linq.Expressions;

namespace Scala.Compiler.Ast
{
    public class PackageDefStatement:Statement
    {
        private readonly string _pid;
        private readonly IList<Statement> _stats;

        public PackageDefStatement(string pid, IList<Statement> stats)
        {
            _pid = pid;
            Scope = new ScalaScope(pid);
            Scope.IsPackage = true;
            _stats = stats;
        }

        public string PId { get { return _pid; } }
        public IList<Statement> Statements { get { return _stats; } }

        public override void Walk(ScalaWalker walker)
        {
            if (walker.Walk(this))
            {
                if (_stats != null)
                {
                    foreach (Statement s in _stats) { s.Walk(walker); }
                }
            }
            walker.PostWalk(this);
        }

        public override Microsoft.Scripting.Ast.Expression Reduce()
        {
            foreach (var stat in Statements)
            {
                stat.Reduce();
            }
            return Expression.Empty();
        }
    }
}
